package com.qf.ssm01.service.impl;

import com.qf.ssm01.dao.UserDao;
import com.qf.ssm01.entity.User;
import com.qf.ssm01.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public User findUser(Integer id) {

        // service 层的业务逻辑
        if(id<0){
            System.out.println("id无效");
            User user = new User();
            user.setId(-1);
            user.setName("无效的用户");
            return user;
        }
        User user = userDao.getUserById(id);
        return user;
    }
}
